package net;

import java.io.BufferedReader;  
 import java.io.IOException;  
 import java.io.InputStreamReader;  
 import java.net.MalformedURLException;  
 import java.net.Authenticator;  
 import java.net.PasswordAuthentication;  
 import java.net.URL;  
 import java.net.URLConnection; 

public class ConnectHttps {
	  public static void main(String[] args)  
	     throws MalformedURLException, IOException {  
	   
	       URL url = new URL("https://algun_servidor...");  
	       URLConnection con = url.openConnection();  
	  
	       Authenticator au = new Authenticator() {  
	          
	          protected PasswordAuthentication  
	             getPasswordAuthentication() {  
	             return new PasswordAuthentication  
	               ("usuario", "clave".toCharArray());  
	          }  
	       };  
	       Authenticator.setDefault(au);  
	   
	      BufferedReader in = new BufferedReader(  
	          new InputStreamReader(con.getInputStream()));  
	   
	       String linea;  
	       while ((linea = in.readLine()) != null) {  
	          System.out.println(linea);  
	       }  
	    }  
}
